package cn.richard.demo.logback;

import java.time.LocalDateTime;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import lombok.extern.slf4j.Slf4j;

@Slf4j
@Controller
public class TestCtrller {
	@Value("${server.port}")
	private int port;

	@GetMapping("/hello")
	@ResponseBody
	public String hello() {
		return "Hello@port:" + port + "@time:" + LocalDateTime.now().toString();
	}
	
	@GetMapping("/logback/many")
	public String logback_many() {
		int s = 10;
		for(int i=0; i<s; i++) {
			log.trace(">> log trace {}", i+1);
		}
		
		for(int i=0; i<s; i++) {
			log.debug(">> log debug {}", i+1);
		}
		
		for(int i=0; i<s; i++) {
			log.info(">> log info {}", i+1);
		}
		
		for(int i=0; i<s; i++) {
			log.warn(">> log warn {}", i+1);
		}
		
		for(int i=0; i<s; i++) {
			log.error(">> log error {}", i+1);
		}
		
		return "redirect:/";
	}
}
